<template>
	<view class="template-order">
		<!-- 顶部自定义导航 -->
		<tn-nav-bar fixed :isBack="true" backgroundColor="#4169E1" class="tatils" :bottomShadow="false">我的收藏
		</tn-nav-bar>

		<view class="order--wrap" :style="{top: vuex_custom_bar_height + 'px'}">
			<!-- 顶部标签 -->
			<view class="tn-bg-white" style="height: 40px;background-color: #ffffff;display: block;">
				<tn-tabs-swiper class="order__tabs" ref="tabs" activeColor="#3165CC" inactiveColor="#080808"
					:list="list" :current="tabsIndex" :isScroll="false" @change="tabsChange"></tn-tabs-swiper>
			</view>
			<!-- 标签内容 -->
			<swiper class="order__swiper" :style="{top: `${swiperTop}px`, height: `${swiperHeight}px`}"
				:current="swiperIndex" @transition="swiperTransition" @animationfinish="swiperAnimationFinish">
				<swiper-item class="order__swiper__item">
					<scroll-view :style="{height: `${swiperHeight}px`}" scroll-y>
						<view v-for="(item,index) in hylist" :key="index" class="order__item">
							<view
								class="order__item__head tn-flex tn-flex-direction-row tn-flex-col-center tn-flex-row-between">
								<view class="order__item__head__title">{{item.cname}}<text
										class="order__item__head__title--right-icon tn-icon-right"></text></view>
								<view class="order__item__head__status" style="color: #4169E1;font-size: 16px;">货源
								</view>
							</view>
							<view
								class="order__item__content tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-center">
								<view class="order__item__content__image" style="width: 20%;">
									<image :src="item.imagelist[0]" mode="scaleToFill">
									</image>
								</view>
								<view style="width: 80%;height: 70px;">
									<view class="order__item__content__title" style="font-size: 16px;font-weight: 600;">
										{{item.title}}
									</view>
									<view style="overflow: hidden;margin-top: 5px;">
										<view style="color: #A93023;font-size: 16px;float: left;width: 50%;">
											{{item.num}}吨
										</view>
										<view
											style="color: #A93023;font-size: 16px;float: left;width: 50%;text-align: right;">
											{{item.jtime}}小时
										</view>
									</view>

									<view style="overflow: hidden;margin-top: 5px;">
										<view style="font-size: 16px;float: left;width: 50%;">
											{{item.address}}
										</view>
										<view
											style="color: #A93023;font-size: 16px;float: left;width: 50%;text-align: right;">
											浏览:{{item.konum}}
										</view>
									</view>
								</view>
							</view>
							<!-- <view
								class="order__item__operation tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-between">
								<view class="order__item__operaation__left">
									<text class="order__item__operaation__left--text">{{item.num}}吨</text>
								</view>
								<view
									class="order__item__operation__right tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-right">
								</view>
							</view> -->
						</view>
						<view class="tn-padding-bottom"></view>
					</scroll-view>
				</swiper-item>

				<swiper-item class="order__swiper__item">
					<scroll-view :style="{height: `${swiperHeight}px`}" scroll-y>
						<view v-for="(item,index) in cglist" :key="index" class="order__item">
							<view
								class="order__item__head tn-flex tn-flex-direction-row tn-flex-col-center tn-flex-row-between">
								<view class="order__item__head__title">{{item.cname}}<text
										class="order__item__head__title--right-icon tn-icon-right"></text></view>
								<view class="order__item__head__status" style="color: #ff557f;font-size: 16px;">供应
								</view>
							</view>

							<view
								class="order__item__content tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-center">
								<view class="order__item__content__image" style="width: 20%;">
									<image :src="item.imagelist[0]" mode="scaleToFill">
									</image>
								</view>
								<view style="width: 80%;height: 70px;">
									<view class="order__item__content__title" style="font-size: 16px;font-weight: 600;">
										{{item.title}}
									</view>
									<view style="overflow: hidden;margin-top: 5px;">
										<view style="color: #A93023;font-size: 16px;float: left;width: 50%;">
											{{item.num}}吨
										</view>
										<view
											style="color: #A93023;font-size: 16px;float: left;width: 50%;text-align: right;">
											{{item.jtime}}小时
										</view>
									</view>

									<view style="overflow: hidden;margin-top: 5px;">
										<view style="font-size: 16px;float: left;width: 50%;">
											{{item.address}}
										</view>
										<view
											style="color: #A93023;font-size: 16px;float: left;width: 50%;text-align: right;">
											浏览:{{item.konum}}
										</view>
									</view>
								</view>
							</view>
							<!-- <view
					class="order__item__operation tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-between">
					<view class="order__item__operaation__left">
						<text class="order__item__operaation__left--text">{{item.num}}吨</text>
					</view>
					<view
						class="order__item__operation__right tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-right">
					</view>
				</view> -->
						</view>
						<view class="tn-padding-bottom"></view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="order__swiper__item">
					<scroll-view :style="{height: `${swiperHeight}px`}" scroll-y>
						<view v-for="(item,index) in zblist" :key="index" class="order__item">
							<view
								class="order__item__head tn-flex tn-flex-direction-row tn-flex-col-center tn-flex-row-between">
								<view class="order__item__head__title">{{item.cname}}<text
										class="order__item__head__title--right-icon tn-icon-right"></text></view>
								<view class="order__item__head__status" style="color: #4169E1;font-size: 16px;">招标
								</view>
							</view>
							<view
								class="order__item__content tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-center">
							<!-- 	<view class="order__item__content__image" style="width: 20%;">
									<image :src="item.imagelist[0]" mode="scaleToFill">
									</image>
								</view> -->
								<view style="width: 100%;height: 70px;">
									<view class="order__item__content__title" style="font-size: 16px;font-weight: 600;">
										{{item.title}}
									</view>
									<view style="overflow: hidden;margin-top: 15px;">
										<view style="font-size: 16px;float: left;width: 50%;">
											{{item.address}}
										</view>
										<view
											style="color: #A93023;font-size: 16px;float: left;width: 50%;text-align: right;">
											浏览:{{item.konum}}
										</view>
									</view>
								</view>
							</view>
							<!-- <view
					class="order__item__operation tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-between">
					<view class="order__item__operaation__left">
						<text class="order__item__operaation__left--text">{{item.num}}吨</text>
					</view>
					<view
						class="order__item__operation__right tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-right">
					</view>
				</view> -->
						</view>
						<view class="tn-padding-bottom"></view>
					</scroll-view>
				</swiper-item>



			</swiper>
		</view>



	</view>
</template>

<script>
	import {
		getzbListalluidsc,
		gethyListalluidsc,
		getcgListalluidsc
	} from '@/apis/uinfo.js'
	import {getToken,setToken,removeToken,getLogins} from '@/utils/auth';
	import templatePageMixin from '@/libs/mixin/template_page_mixin.js'
	export default {
		name: 'TemplateOrder',
		mixins: [templatePageMixin],
		data() {
			return {
				list: [{
						name: '货源'
					},
					{
						name: '供应'
					},
					{
						name: '招标'
					},
					// {name: '待收货'},
					// {name: '待评价', count: 5}
				],
				tabsIndex: 0,
				swiperIndex: 0,
				swiperTop: 0,
				swiperHeight: 0,
				hylist: [],
				zblist: [],
				cglist: []
			}
		},
		onLoad() {
			getLogins()
		},
		onReady() {
			this.$nextTick(() => {
				this.updateSwiperInfo()
				this.gethyListalluids()
				this.getzbListalluids()
				this.getcgListalluids()
			})
		},
		methods: {
			//我的货源			
			gethyListalluids() {
				let data = {
					uid: uni.getStorageSync('uid')
				}
				gethyListalluidsc(data).then(res => {
					console.log(res)
					if (res.code == 200) {
						this.hylist = res.data
					}
				}).catch(error => {
					that.tool.toastTip('货源分类报错', 'none', 1000)
				})
			},
			//我的招标
			getzbListalluids() {
				let data = {
					uid: uni.getStorageSync('uid')
				}
				getzbListalluidsc(data).then(res => {
					console.log(res)
					if (res.code == 200) {
						this.zblist = res.data
					}
				}).catch(error => {
					this.tool.toastTip('货源分类报错', 'none', 1000)
				})
			},

			//我的供应	  
			getcgListalluids() {
				let data = {
					uid: uni.getStorageSync('uid')
				}
				getcgListalluidsc(data).then(res => {
					console.log(res)
					if (res.code == 200) {
						this.cglist = res.data
					}
				}).catch(error => {
					that.tool.toastTip('货源分类报错', 'none', 1000)
				})
			},
			// 计算可滑动区域的高度信息
			updateSwiperInfo() {
				// 获取可滑动菜单的信息
				this._tGetRect('.order__tabs').then(res => {
					if (!res) {
						setTimeout(() => {
							this.updateSwiperInfo()
						}, 10)
						return
					}
					const systemInfo = uni.getSystemInfoSync()
					// this.swiperTop = res.bottom - this.vuex_custom_bar_height
					this.swiperTop = 20
					this.swiperHeight = systemInfo.safeArea.height - res.bottom + systemInfo.statusBarHeight
				})
			},
			// 标签栏值发生改变
			tabsChange(index) {
				this.swiperIndex = index
			},
			// swiper-item位置发生改变
			swiperTransition(event) {
				this.$refs.tabs.setDx(event.detail.dx)
			},
			// swiper动画结束
			swiperAnimationFinish(event) {
				const current = event.detail.current
				this.$refs.tabs.setFinishCurrent(current)
				this.swiperIndex = current
				this.tabsIndex = current
			}
		}
	}
</script>

<style lang="scss" scoped>
	.template-order {
		background-color: #ffffffcc;
	}

	.tatils {
		color: #fff;
	}

	/* 自定义导航栏内容 start */
	.custom-nav {
		height: 100%;

		&__back {
			// margin: auto 5rpx;
			font-size: 40rpx;
			flex-basis: 5%;
			padding: 20rpx 40rpx 20rpx 30rpx;
		}

		&__search {
			flex-basis: 55%;
			width: 100%;
			height: 100%;

			&__box {
				width: 100%;
				height: 60%;
				padding: 28rpx 0;
				margin: 0 30rpx;
				border-radius: 60rpx;
				font-size: 24rpx;
				background-color: #FFFFFF;
				border: 1rpx solid #F8F7F8;
			}

			&__icon {
				padding-right: 10rpx;
				margin-left: 20rpx;
				font-size: 30rpx;
			}

			&__text {
				color: #AAAAAA;
			}
		}
	}

	/* 自定义导航栏内容 end */

	.order {
		&--wrap {
			position: fixed;
			left: 0;
			right: 0;
			width: 100%;
			background-color: inherit;
		}

		/* 导航栏 start */
		&__tabs {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			background-color: inherit;
		}

		/* 导航栏 end */

		/* swiper start */
		&__swiper {
			position: absolute;
			left: 0;
			right: 0;
			width: 100%;
			background-color: inherit;
			// padding: 0 16rpx;
		}

		/* swiper end */

		/* 订单内容 start */
		&__item {
			margin: 20rpx;
			padding: 36rpx 26rpx;
			background-color: #FFFFFF;
			border-radius: 18rpx;

			&:first-child {
				margin-top: 40rpx;
			}

			&:last-child {
				margin-bottom: 0;
			}

			/* 头部 start */
			&__head {

				&__title {
					font-weight: bold;
					line-height: normal;

					&--right-icon {
						font-size: 24rpx;
						margin-left: 8rpx;
					}
				}

				&__status {
					font-size: 22rpx;
					color: #AAAAAA;
				}
			}

			/* 头部 end */

			/* 内容 start */
			&__content {

				margin-top: 20rpx;

				&__image {
					margin-right: 20rpx;

					image {
						width: 140rpx;
						height: 140rpx;
						border-radius: 10rpx;
					}
				}

				&__title {
					padding-right: 40rpx;
					display: -webkit-box;
					overflow: hidden;
					white-space: normal !important;
					text-overflow: ellipsis;
					word-wrap: break-word;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
				}

				&__info {

					&__price {
						&--unit {
							font-size: 20rpx;
						}

						&__value--integer,
						&__value--decimal {
							font-weight: bold;
						}

						&__value--decimal {
							font-size: 20rpx;
						}
					}

					&__count {
						color: #AAAAAA;
						font-size: 24rpx;
					}
				}
			}

			/* 内容 end */

			/* 操作按钮 start */
			&__operation {
				margin-top: 30rpx;

				&__right {
					&__button {
						margin-left: 10rpx;
					}
				}
			}

			/* 操作按钮 end */
		}

		/* 订单内容 end */
	}
</style>